home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovieWP.py < prev    next >
Text File  |  2008-11-17  |  5KB  |  151 lines

  1. # -*- coding: utf-8 -*-
  2.  
  3. __revision__ = '$Id: PluginMovieWP.py 1040 2008-11-15 21:13:49Z mikej06 $'
  4.  
  5. # Copyright (c) 2005-2007 Piotr O┼╝arowski
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  20.  
  21. # You may use and distribute this software under the terms of the
  22. # GNU General Public License, version 2 or later
  23.  
  24. import gutils
  25. import movie,string
  26. import re
  27.  
  28. plugin_name         = 'Wirtualna Polska'
  29. plugin_description  = 'Serwis filmowy Wirtualnej Polski'
  30. plugin_url          = 'www.film.wp.pl'
  31. plugin_language     = _('Polish')
  32. plugin_author       = 'Piotr O┼╝arowski'
  33. plugin_author_email = '<ozarow+griffith@gmail.com>'
  34. plugin_version      = '2.3'
  35.  
  36. class Plugin(movie.Movie):
  37.     def __init__(self, id):
  38.         self.movie_id = id
  39.         self.url = "http://film.wp.pl/id,%s,film_szczegoly.html" % self.movie_id
  40.         self.encode='iso-8859-2'
  41.  
  42.     def initialize(self):
  43.         self.page = gutils.trim(self.page, '<h1 class="mp0">', '</div>\n</div>')
  44.         self.cast_page = self.open_page(url="http://film.wp.pl/id,%s,film_obsada_i_tworcy.html" % self.movie_id)
  45.         self.cast_page = gutils.trim(self.cast_page, '<h1 class="mp0">', "</div>\r\n</div>\r\n")
  46.  
  47.     def get_image(self):
  48.         self.image_url = gutils.trim(self.page, '<img src="', '" name="o')
  49.  
  50.     def get_o_title(self):
  51.         self.o_title = gutils.trim(self.page, '<b>Tytu\xB3 orygina\xB3u:</b>', "\t\t</div><div")
  52.         self.o_title = gutils.clean(self.o_title)
  53.         if self.o_title == '':
  54.             self.o_title = gutils.trim(self.page, '</h1>', '<div')
  55.  
  56.     def get_title(self):
  57.         self.title = gutils.trim(self.page, '<b>Tytu\xB3 polski:</b>', "\t\t</div><div")
  58.         if self.title == '':
  59.             self.title = gutils.before(self.page, '</h1>')
  60.             pos = string.find(self.title, '(')
  61.             if pos > -1:
  62.                 self.title = self.title[:pos]
  63.  
  64.     def get_director(self):
  65.         self.director = gutils.trim(self.cast_page, '>re\xBFyser\t</div>', '</div>')
  66.  
  67.     def get_plot(self):
  68.         self.plot = gutils.trim(self.page, ' />', '\t\t<div class="clr">')
  69.         pos = string.find(self.plot, "<br>Zobacz tak\xBFe:<br>")
  70.         if pos > 0:
  71.             self.plot = self.plot[:pos]
  72.         self.plot = string.replace(self.plot,"\r\n\r\n", '')
  73.  
  74.     def get_year(self):
  75.         self.year = gutils.trim(self.page, '<b>Rok produkcji:</b>', "\t\t</div><div")
  76.         year = re.findall(r'\d+', self.year)
  77.         if len(year)>0:
  78.             self.year = year[0]
  79.  
  80.     def get_runtime(self):
  81.         self.runtime = gutils.trim(self.page, '<b>Czas trwania:</b>', 'min')
  82.         runtime =  re.findall(r'\d+', self.runtime)
  83.         if len(runtime)>0:
  84.             self.runtime = runtime
  85.  
  86.     def get_genre(self):
  87.         self.genre = gutils.trim(self.page, '<b>Gatunek:</b>', "\t\t</div><div")
  88.         self.genre = string.replace(self.genre, '<br />    ', '')
  89.         self.genre = string.replace(self.genre, '<br />', ' / ')
  90.  
  91.     def get_cast(self):
  92.         self.cast = gutils.trim(self.cast_page, '<h2>OBSADA:</h2>', '<div class="b')
  93.         self.cast = gutils.after(self.cast, '<div class="clr"></div>')
  94.         self.cast = string.replace(self.cast, '\t', '')
  95.         self.cast = string.replace(self.cast, '\n</div>\n<', _(' as ')+'<')
  96.         self.cast = gutils.strip_tags(self.cast)
  97.         self.cast = string.replace(self.cast,  "%s\n" % _(' as '), "\n")
  98.  
  99.     def get_classification(self):
  100.         self.classification = gutils.trim(self.page, '<b>Przedzia\xB3 wiekowy:</b>', "\t\t</div><div")
  101.         self.classification = gutils.trim(self.classification, 'od ', ' ')
  102.  
  103.     def get_studio(self):
  104.         self.studio = gutils.trim(self.page, '<b>Wytw\xF3rnia:</b>', "\t\t</div><div")
  105.  
  106.     def get_o_site(self):
  107.         self.o_site = ''
  108.  
  109.     def get_site(self):
  110.         self.site = "http://film.wp.pl/id,%s,film.html" % self.movie_id
  111.  
  112.     def get_trailer(self):
  113.         self.trailer = "http://film.wp.pl/id,%s,film_trailer.html" % self.movie_id
  114.  
  115.     def get_country(self):
  116.         pos = self.page.find('<b>Kraj produkcji:</b>')
  117.         if pos == -1:
  118.             pos = self.page.find('<b>Kraje produkcji:</b>')
  119.         if pos > -1:
  120.             self.country = gutils.trim(self.page[pos:], '</b>', "\t\t</div><div")
  121.  
  122.     def get_rating(self):
  123.         self.rating = None
  124.  
  125.     def get_notes(self):
  126.         self.notes = ''
  127.  
  128. class SearchPlugin(movie.SearchMovie):
  129.     def __init__(self):
  130.         self.encode='iso-8859-2'
  131.         self.original_url_search    = 'http://film.wp.pl/szukaj,%s,type,f,szukaj.html'
  132.         self.translated_url_search    = 'http://film.wp.pl/szukaj,%s,type,f,szukaj.html'
  133.  
  134.     def search(self,parent_window):
  135.         self.open_search(parent_window)
  136.         self.page = gutils.trim(self.page, '<div id="filmUS"', '<div id=');
  137.         return self.page
  138.  
  139.     def get_searches(self):
  140.         elements = string.split(self.page, '</div><br />')
  141.         self.number_results = elements[-1]
  142.  
  143.         if elements[0] != '':
  144.             for element in elements:
  145.                 tmp_id = gutils.trim(element,'<div class="rgt"><a href="id,', ',')
  146.                 self.ids.append(tmp_id)
  147.                 tmp_title = gutils.trim(element, 'html"><b>', '</b>')
  148.                 self.titles.append(tmp_title)
  149.         else:
  150.             self.number_results = 0
  151.